package com.runtime.hongyunuser.bean;

import com.github.wxpay.sdk.WXPayConfig;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class WXPayConfigImpl implements WXPayConfig {
    private String appid;
    private String mch_id;
    private String key;
    private String notify_url;

    // 构造函数注入参数
    public WXPayConfigImpl(String appid, String mch_id, String key, String notify_url) {
        this.appid = appid;
        this.mch_id = mch_id;
        this.key = key;
        this.notify_url = notify_url;
    }

    public WXPayConfigImpl() {
    }

    @Override
    public String getAppID() {
        return appid;
    }

    @Override
    public String getMchID() {
        return mch_id;
    }

    @Override
    public String getKey() {
        return key;
    }

//    @Override
//    public String getNotifyUrl() {
//        return notify_url;
//    }

    // 证书路径配置（生产环境必填）
    @Override
    public InputStream getCertStream() {
        try {
            return new FileInputStream("path/to/apiclient_cert.p12");
        } catch (FileNotFoundException e) {
            throw new RuntimeException("证书加载失败", e);
        }
    }

    // 超时时间配置
    @Override
    public int getHttpConnectTimeoutMs() {
        return 8000; // 8秒
    }

    @Override
    public int getHttpReadTimeoutMs() {
        return 10000; // 10秒
    }
}
